package com.sofwin.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.sofwin.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @packageName: com.sofwin.controller
 * @author: andyliu
 * @date: 2022/5/18 11:34
 * @email 115176513@qq.com
 * @description: TODO
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @GetMapping("/data")
    @SentinelResource("data1")
    public User getUsers(Integer userId, String userName){
        User user = new User();
        user.setId(userId);
        user.setUserName(userName);
        System.out.println("data method invoke.....");
        return user;
    }
    @GetMapping("/data2")
    @SentinelResource("data2")
    public User getUsers2(Integer userId, String userName){
        User user = new User();
        user.setId(userId);
        user.setUserName(userName);
        System.out.println("data method invoke.....");
        return user;
    }
    @GetMapping("a")
    public User a(Integer id,String userName){
        User user = new User();
        user.setId(id);
        user.setUserName(userName);
        return user;
    }
    @RequestMapping("/info/{id}")
    @SentinelResource("resource1")
    public String userInfo(@PathVariable Integer id){
        System.out.println("***provider02");
        return "admin"+id;
    }
    @GetMapping("test")
    public User test(User user){
        return user;
    }
}
